<script type="text/javascript">
function changeStatus(obj,index){
   document.getElementById("txtPrice_" + index).disabled = ! obj.checked;
   document.getElementById("txtQty_" + index).disabled = ! obj.checked;
   document.getElementById("txtDisc_" + index).disabled = ! obj.checked;
}
</script>
<div>Keranjang Anda:&nbsp;<a href="<?php echo site_url('penjualancontroller/showFormPenjualan')?>"><?php echo count($this->cart->contents())?>&nbsp;</a>Item</div>
<form id="frmPenjualan" name="frmPenjualan" method="post" action="<?php echo site_url('penjualancontroller/addtocart');?>">
<table border="0" cellpadding="3" cellspacing="0" width="100%" style=" border-collapse: collapse;" class="record" bordercolor="#CCCCCC">
	<thead>
        <tr style="background-color:#FFF; color:#000000;" align="center">
            <td colspan="7" height="25">PILIH PRODUK</td>
        </tr>
        <tr class="tableCellHeader">
            <th style="width:15px;">&nbsp;</th>
            <th style="width:45px;">Kode Barang</th>
            <th>Nama Barang</th>
            <th>Kategori</th>
            <th>Harga Barang</th>
            <th>Jumlah</th>
            <th>Disc %</th>
        </tr>
    </thead>
    <tbody id="datastock"><?php
		$i = 0; 
		if(count($array_stock)>0){
			foreach($array_stock as $data){
				$style = "";
				if($i%2 == 0)$style="cellDefault"; else $style="cellAlternate";
				$disables = ($array_stock[$i]->stokakhir == "0") ? 'disabled="disabled"' : '';
            	echo '<tr class="'.$style.'">';                    	
            	echo '<td><input type="checkbox" id="chkitem[]" name="chkitem[]" value="'.$data->kodedetailbarang.'" onclick="javascript:changeStatus(this, '.$i.')" '.$disables.'/></td>';
                echo '<td>'.$data->kodedetailbarang.'</td>';
                echo '<td>'.$data->itemname.'</td>';
                echo '<td>'.$data->itemcategory.'</td>';
                echo '<td>Rp&nbsp;<input type="text" id="txtPrice_'.$i.'" name="txtPrice[]" maxlength="11" value="'.$data->itemprice.'" disabled="disabled"/></td>';
                echo '<td><input type="text" id="txtQty_'.$i.'" name="txtQty[]" maxlength="9" disabled="disabled" />&nbsp;'.$data->typeunit.'</td>';
                echo '<td><input type="text" id="txtDisc_'.$i.'" name="txtDisc[]" maxlength="5" disabled="disabled" /></td>';
            	echo '</tr>';        
        		$i++;
        	}
		} else{
            echo "<tr>";
            echo "<td colspan='9' style='text-align:center;color:red;'>No Data To Display</td>";
            echo "</tr>";
    } ?></tbody>
</table>
<div id="stock" class="holder"></div>
<br/>
<br/>
<input type="submit" id="btnaddcart" value="Tambah keranjang" title="Tambahkan ke keranjang belanja" />
<input type="button" id="btnbacktocategory" value="Kembali ke kategori" onclick="window.location='<?php echo site_url('penjualancontroller')?>';" />
</form>